//
//  TGInfoTextView.m
//  GroupBuy
//
//  Created by wwj on 15/11/16.
//  Copyright © 2015年 wwj. All rights reserved.
//

#import "TGInfoTextView.h"
#import "NSString+Extend.h"
@interface TGInfoTextView ()
@property (weak, nonatomic) IBOutlet UIButton *titleView;
@property (weak, nonatomic) IBOutlet UILabel *contentView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentH;

@end
@implementation TGInfoTextView

+(instancetype)infoTextView{
    return [[NSBundle mainBundle] loadNibNamed:@"TGInfoTextView" owner:nil options:nil].lastObject;
}
-(void)setIcon:(NSString *)icon{
    _icon = icon;
    [_titleView setImage:[UIImage imageNamed:icon] forState:UIControlStateNormal];
}

-(void)setTitle:(NSString *)title{
    _title = title;
    [_titleView setTitle:title forState:UIControlStateNormal];
}

-(void)layoutSubviews{
    _contentH.constant = [_content sizeWithFont:[UIFont systemFontOfSize:15] maxSize:CGSizeMake(self.frame.size.width, MAXFLOAT)].height;
    CGRect frame = _contentView.frame;
    frame.size.height = _contentH.constant;
    _contentView.frame = frame;
    
    CGRect sframe = self.frame;
    sframe.size.height = CGRectGetMaxY(_contentView.frame)+10;
    self.frame = sframe;
    self.autoresizingMask = UIViewAutoresizingFlexibleHeight;
}

-(void)setContent:(NSString *)content{
    _content = content;
    _contentView.text = _content;
    [self layoutSubviews];
}

@end
